/*
	fmtunePlugin.h

	Copyright (c) 2009 by Lms <lms.cze7@gmail.com>

 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************
*/

#ifndef fmtunePlugin_H
#define fmtunePlugin_H

#include <qutim/plugininterface.h>
#include <QtNetwork>
#include <QtXml>
#include <QHash>
#include <QMenu>
#include <QWidgetAction>
#include <QDateTime>
#include <QtSql>
#include <QShortcut>
#include <QSlider>
#include <QClipboard>

#include "fmtuneSettings.h"

#include "info.h"
#include "equalizer.h"
#include "recording.h"
#include "editstations.h"
#include "fastaddstation.h"
#include "sqliteengine.h"

#ifdef useBASS
#include "bassfce.h"
#else	//PHONON
#include <phonondefs.h>
#include <mediaobject.h>
#include <mediasource.h>
#include <audiooutput.h>
#endif

#include "general.h"

#include "3rdparty/globalshortcut/globalshortcutmanager.h"
#include "TreeComboBox/TreeComboBox.h"

using namespace qutim_sdk_0_2;

class fmtunePlugin : public QObject, SimplePluginInterface, EventHandler
{
	Q_OBJECT
	Q_INTERFACES(qutim_sdk_0_2::PluginInterface)

public:
	virtual bool init(PluginSystemInterface *plugin_system);
	virtual void release();
	virtual void processEvent(Event &event);
	virtual QWidget *settingsWidget();
	virtual void setProfileName(const QString &profileName);
	virtual QString name();
	virtual QString description();
	virtual QString type();
	virtual QIcon *icon();
	virtual void removeSettingsWidget();
	virtual void saveSettings();
	
	void load();

	void createContextMenu();
	void loadStations();

private slots:
	void actionRadioOnOff();
	void actionCopySongName();
	void actionInfo();
	void actionEqualizer();
	void actionRecording();
	void actionEditStations();
	void actionFastAddStation();

	void refreshtimerTimeout();

	void actionaboutToShow();

	void actionStations_Changed();
	void actionStreams_Changed();

	void actionShortcutRadioOnOff();
	void actionShortcutVolumeUp();
	void actionShortcutVolumeDown();
	void actionShortcutVolumeMute();

	void actionVolumeChanged(int val);
	void actionMuteChanged(int val);


private:
#ifndef useBASS
	Phonon::MediaObject *phononStream;
	Phonon::AudioOutput *phononOutput;
#endif
	QIcon *fmtunePluginIcon;
	PluginSystemInterface *fmtunePluginSystem;
	QString m_profile_name;

	TreeModelItem eventItem;
	
	fmtuneSettings *m_settings_widget;

//	QHash<QString, wwwewe> weweweList;
//	QNetworkAccessManager *netMan;

	QMenu *m_item_menu;

	QLabel *menu_title_label;
	QWidgetAction *menu_action_title;

	/*TreeComboBox*/ QComboBox *menu_stations_combo;
	QWidgetAction *menu_action_stations;

	QComboBox *menu_streams_combo;
	QWidgetAction *menu_action_streams;

	QAction *menu_action_On;
	QAction *menu_action_Off;
	QAction *menu_action_CopySongName;
	QAction *menu_action_Info;
	QAction *menu_action_Equalizer;
	QAction *menu_action_Recording;
	QAction *menu_action_EditStations;
	QAction *menu_action_FastAddStation;

	QMenu *m_item_menu_volume;

	QSlider *menu_volume_slider_slider;
	QWidgetAction *menu_action_volume_slider;

	QLabel *menu_volume_value_label;
	QWidgetAction *menu_action_volume_value;

	QCheckBox *menu_volume_mute_check;
	QWidgetAction *menu_action_volume_mute;

	QLabel *menu_volume_icon_unmute_label;
	QWidgetAction *menu_action_volume_icon_unmute;

	QLabel *menu_volume_icon_mute_label;
	QWidgetAction *menu_action_volume_icon_mute;


	int interval;
	bool showstatus;

	Info *m_info;
	Equalizer *m_equalizer;
	Recording *m_recording;
	EditStations *m_editstations;
	FastAddStation *m_fastaddstation;

	QTimer *refreshtimer;

	qint16 m_event_init,
		m_event_context,
		m_event_tooltip,
		m_event_additional_info,
		m_event_receivelevel3;

	SQLiteEngine sqldb;
};

#endif
